import { getUserInfo } from '@/services/auth'

const state = {
	userInfo: {
		is_vip: true,
		usage: {
			total_chars: 0, 
			total_count: 0, 
			remaining_count: null, 
			daily_limit: null, 
			chars_limit: null
		},
		user_info: {
			nickname: "", 
			avatar: "", 
			city: null, 
			country: null, 
			gender: 0, 
			nickname: "", 
			province: null
		},
	}
}

const mutations = {
	SET_USER_INFO(state, userInfo) {
		state.userInfo = userInfo
	}
}

const actions = {
	async getUserInfo({ commit }) {
		try {
			const response = await getUserInfo()
			commit('SET_USER_INFO', response)
			console.log('用户信息结果:', response)
			return response.data
		} catch (error) {
			console.error('获取配置失败:', error)
			throw error
		}
	},
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
} 